// i.d(t, { I: () => RoomValueMap })

export default class RoomValueMap<T = string> {
  values: Map<number, T>
  constructor() {
    this.values = new Map()
  }
  get(e: number, t: number) {
    const i = RoomValueMap.keyFromGroupValues(e, t)
    return this.values.get(i)
  }
  set(e: number, t: number, i: T) {
    const n = RoomValueMap.keyFromGroupValues(e, t)
    this.values.set(n, i)
  }
  [Symbol.iterator]() {
    let e = 0
    const t = Array.from(this.values.entries())
    return {
      next() {
        if (e < t.length) {
          const i = t[e++],
            { meshGroup, meshSubgroup } = RoomValueMap.groupValuesFromKey(i[0])
          return {
            done: !1,
            value: { meshGroup, meshSubgroup, value: i[1] }
          }
        }
        return { done: !0, value: null }
      }
    }
  }
  static keyFromGroupValues(e: number, t: number) {
    return (e << 16) + t
  }
  static groupValuesFromKey(e: number) {
    return { meshGroup: e >> 16, meshSubgroup: 65535 & e }
  }
}
